<style>
.edui-editor-bottomContainer{}
</style>
		<div class="ui-portlet">
			{{template wxes/_user_wxes}}
			<ol class="breadcrumb">
			  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;微信菜单</a></li>
			  <li class="active">编辑菜单项</li>
			</ol>
		</div>           
       <hr>
       <h3>微信菜单</h3>
      
<hr>
{{$this->Form->create('WxMenu',array('class'=>'form-horizontal','role'=>'form'))}}
	
	<!-- <div class="form-group"  id="WxMenuType">
		<label class="col-sm-2 control-label">菜单类型</label>
		<div class="col-sm-9 controls select">
			<label id="FristMenu" data-container="body" data-trigger="hover" data-toggle="popover" data-placement="top" name="mt" style="cursor:pointer;" data-content="无需设置上级与点击事件"  title="需要添加下级的菜单"><input name="mt" type="radio">一级菜单</label>
			<label id="SecondMenu" data-container="body" data-trigger="hover" data-toggle="popover" data-placement="top" name="mt" style="cursor:pointer;" data-content="设置上级后，再设置打开连接或事件"  title="二级菜单有上级"><input name="mt" type="radio">二级菜单</label>
			
			<label id="TopMenu" data-container="body" data-trigger="hover" data-toggle="popover" data-placement="top" style="cursor:pointer;" data-content="需要设置打开连接或者回复规则" title="无下级的一级菜单" ><input name="mt" type="radio">顶级菜单</label>
			
		</div>
	</div> -->
	
	<div class="form-group">
		<label class="col-sm-2 control-label" for="WxMenuName">菜单名称</label>
		<div class="col-sm-9 controls">
			<input type="hidden" name="data[WxMenu][referer]" value="/wx_menus/mine?group={{$_REQUEST['group']}}">
			{{$this->Form->hidden('id')}}{{$this->Form->hidden('group')}}
			{{$this->Form->input('name',array('class'=>'form-control','required'=>'required','div'=>false,'label'=>false))}}
			<small>一级菜单标题长度不超过5个汉字(16个字节)，子菜单长度不超过13个汉字(40个字节)..</small>
		</div>
	</div>
	
	{{if $_REQUEST['type']}}
		{{$this->Form->hidden('visible',array('value'=>1))}}
	{{/if}}
	
	<div class="form-group" id="WxMenuParent">
		<label class="col-sm-2 control-label">上级菜单</label>
		<div class="col-sm-9 controls select">
			{{$this->Form->input('parent_id',array('class'=>'form-control','div'=>false,'label'=>false))}}
			<small>一级菜单无需设置上级</small>
		</div>
	</div>
	
	{{if $_REQUEST['group'] == 2}}
	
		{{if $_REQUEST['type']=='view' }}
			{{$this->Form->hidden('type',array('value'=>'view'))}}
			<div class="form-group" id="divWxMenuLink">
				<label class="col-sm-2 control-label" for="WxMenuUrl">打开url地址</label>
				<div class="col-sm-9 controls">
					{{$this->Form->input('link',array('class'=>'form-control','type'=>"url",'div'=>false,'label'=>false))}}
				</div>
			</div>
		{{elseif in_array($_REQUEST['type'],array('click','text','news')) || $_REQUEST['type']=='media_id' && $current_wxinfo['Wx']['verify_type'] != -1  }}
			{{$this->Form->hidden('type',array('value'=>'media_id'))}}
			<div>
			  <ul class="nav nav-tabs" role="tablist" style="padding-left: 17%;">
			    <li role="presentation" class="active"><a href="#news-weixin" onclick="$('#WxMenuType').val('media_id');" aria-controls="home" role="tab" data-toggle="tab">微信图文素材</a></li>
			    <li role="presentation"><a href="#news-custom"  onclick="$('#WxMenuType').val('click');" aria-controls="profile" role="tab" data-toggle="tab">回复规则</a></li>
			  </ul>
			  <div class="tab-content"  style="padding:15px 0;">
		    	<div role="tabpanel" class="tab-pane active" id="news-weixin">
		    		<div class="form-group" id="divWxMenuMediaId">
						<label class="col-sm-2 control-label" for="WxMenuKey">图文素材</label>
						<div class="col-sm-9 controls">
							{{$this->Form->input('media_id',array('class'=>'form-control','type'=>'text','readonly'=>'readonly','div'=>false,'label'=>false))}}
							<small>选择微信素材中心的素材</small>
							<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxMenuMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
						</div>
					</div>
				 </div>
				 <div role="tabpanel" class="tab-pane" id="news-custom">
					<div class="form-group">
						<label class="col-sm-2 control-label" for="WxMenuKey">回复规则</label>
						<div class="col-sm-9 controls">
							{{$this->Form->input('slug',array('class'=>'form-control','div'=>false,'maxlength'=>128,'label'=>false))}}
							<small>将按照选择的关键字自动回复规则进行消息回复，长度不超过128字节。 </small>
							<p><a href="javascript:void(0)" class="btn btn-warning btn-sm" onclick="publishController.open_dialog('/wx_auto_replies/mine?operate=select&inajax=1',{'selector':'#WxAutoReply-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-keyword').click(function(){ $('#WxMenuSlug').val( $(this).data('keyword') );$dialog.modal('hide');}) } });" >选择自动回复规则</a></p>
						</div>
					</div>
				</div>
			</div>
			</div>
			
		{{elseif $_REQUEST['type']=='view_limited' }}
			{{$this->Form->hidden('type',array('value'=>'view_limited'))}}
			<div class="form-group" id="divWxMenuMediaId">
				<label class="col-sm-2 control-label" for="WxMenuKey">打开网址</label>
				<div class="col-sm-9 controls">
					{{$this->Form->input('media_id',array('class'=>'form-control','type'=>'text','readonly'=>'readonly','div'=>false,'label'=>false))}}
					<p>未认证用户只允许设置素材中心的素材</p>
					<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxMenuMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
				</div>
			</div>
		{{elseif $_REQUEST['type']=='media_id' }}
			{{$this->Form->hidden('type',array('value'=>'media_id'))}}
			<div class="form-group" id="divWxMenuMediaId">
				<label class="col-sm-2 control-label" for="WxMenuMediaId">回复消息</label>
				<div class="col-sm-9 controls">
					{{$this->Form->input('media_id',array('class'=>'form-control','type'=>'text','readonly'=>'readonly','div'=>false,'label'=>false))}}
					<small>未认证公众号只允许回复腾讯素材中心素材</small>
					<p><a href="javascript:void(0)" class="btn btn-primary btn-sm" onclick="publishController.open_dialog('/wx_msgs/wechat?type=select&inajax=1',{'selector':'#wechat-msg-mine-list',width:900,title:'选择微信素材',callback:function($dialog){$dialog.find('.choose-media').click(function(){ $('#WxMenuMediaId').val( $(this).data('mid') );$dialog.modal('hide');}) } });" >选择素材</a></p>
				</div>
			</div>
		{{/if}}
	{{else}}
		
		<div class="form-group" id="divWxMenuLink">
			<label class="col-sm-2 control-label" for="WxMenuUrl">链接地址</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('link',array('class'=>'form-control','type'=>"url",'maxlength'=>256,'div'=>false,'label'=>false))}}
				<small>打开链接长度不超过256字节</small>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMenuKey">菜单图标</label>
			<div class="col-sm-9 controls">
				{{$this->Swfupload->load('coverimg',array('class'=>'form-control',
				'modelClass'=>'WxMenu',
				'no_db'=>1,'upload_limit'=>1,
				'file_types'=> '*.jpg;*.gif;*.png;*.bmp',
				'isadmin'=>false,
				'div'=>false,'label'=>false))}}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMenuKey">菜单英文名</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('slug',array('class'=>'form-control','div'=>false,'maxlength'=>128,'label'=>false))}}
				<small>将按照选择的关键字自动回复规则进行消息回复，长度不超过128字节。 </small>				
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMenuKey">轮播图标</label>
			<div class="col-sm-9 controls">
				{{$this->Swfupload->load('photos',array('class'=>'form-control',
				'modelClass'=>'WxMenu',
				'upload_limit'=>5,
				'file_types'=> '*.jpg;*.gif;*.png;*.bmp',
				'isadmin'=>false,
				'div'=>false,'label'=>false))}}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMenuKey">是否显示</label>
			<div class="col-sm-9 controls">
				{{$this->Form->input('visible',array('class'=>'form-control','default'=>1,'options'=>array(0=>__('No'),1=>__('Yes')),'div'=>false,'label'=>false))}}
			</div>
		</div>
				
		<div class="form-group">
			<label class="col-sm-2 control-label" for="WxMenuKey">页面内容</label>
			<div class="col-sm-12 controls">
				{{$this->Form->input('content',array('div'=>false,'rows'=>'3','label'=>false))}}
			</div>
		</div>
	
	{{/if}}
	<div class="form-group">
		<label class="col-sm-2 control-label"></label>
		<div class="col-sm-9"><input class="btn btn-primary" type="submit" value="提交"></div>
	</div>
{{$this->Form->end()}}

{{if $_REQUEST['group'] == 2}}
	<section style="border: 0px none; padding: 0px;margin-bottom:15px;">
		    <section class="135brush layout" style="white-space: normal;font-size: 14px; line-height: 25px; margin: 2px auto; padding: 10px 10px; border: 2px dashed #dedcde;max-width: 100%;">
		        <p style="margin: 0 0;">提示：</p>
		        <p style="margin: 0 0;">如果一级菜单下有二级菜单，则该一级菜单只需填写“菜单名称”即可,无需设置回复规则与打开网址</p>
		        
		        <p style="margin: 0 0;">
		            一级菜单标题长度不超过16个字节，子菜单不超过40个字节.
		        </p>
		        <p style="margin: 0 0;">
		           发送消息回复规则长度不超过128字节
		        </p>
		        <p style="margin: 0 0;">
		           打开链接长度不超过256字节
		        </p>
		        <p>1个字母与数字为1字节，1个汉字为3字节</p>
		    </section>
	</section> 
{{/if}}
{{if $_REQUEST['group'] == 1}}
<link href="/cache/96619a5672.css" rel="stylesheet" type="text/css" >
<script type="text/javascript" src="/js/ueditor/ueditor.config.js"></script>
<script src="/js/ueditor/ueditor.all.min.js"></script>
<script src="/open/a92d301d77.js" type="text/javascript"></script>


<?php  
echo $this->Combinator->script(array(
	'ueditor/lang/zh-cn/zh-cn.js',
	'i18n/language-zh-cn.js',
	'jquery/jquery.cookie.js','jquery/jquery.mousewheel.min.js',
	'tinycolor-min.js',
	'135editor.js','jquery/jquery.jgrowl.min.js','metro-ui/slider.js',
	'common.js',
	'front.js',
	'jquery/jquery.mixitup.min.js','jquery/jquery-sortable-min.js',
	'jquery/jquery.lazyload.js'
));
?>

<script>
	var current_editor =  UE.getEditor('WxMenuContent',{
		initialFrameHeight:350,
		open_editor: true,
		style_width:360, //样式区宽度像素
		appkey:'566d34e0-4bac-443b-8a80-37f89fde689a',
		style_url : 'http://www.135editor.com/editor_styles/open?inajax=1&appkey=566d34e0-4bac-443b-8a80-37f89fde689a'
	});
</script>
{{/if}}
<script>
$(function(){
	/*$('#TopMenu').click(function(){
		$('#WxMenuParent').hide();
		$('#divWxMenuLink').show();
		$('#divWxMenuMediaId').show();
		$('#WxMenuParentId').val('');
	});
	
	$('#FristMenu').click(function(){
		$('#WxMenuParent').hide();
		$('#divWxMenuLink').hide();
		$('#divWxMenuMediaId').hide();
		$('#WxMenuParentId').val('');
	}).trigger('click');
	
	$('#SecondMenu').click(function(){
		$('#WxMenuParent').show();
		$('#divWxMenuLink').show();
		$('#divWxMenuMediaId').show();
		//$('#WxMenuParentId').val('');
	});*/
	
	/*$('#WxMenuType').change(function(){
		if($(this).val()=='view'){
			//$('#divWxMenuLink').show();
			$('#divWxMenuSlug').hide();
		}
		else{
			//$('#divWxMenuLink').hide();
			$('#divWxMenuSlug').show();
		}
	}).trigger('change');*/
})
</script>

